package com.gdwhomework.chapter07.homework006;

public class Tools {

    public void person_sort(Person arr[]){
        Person tmp = new Person("tmp", 'n', 0);
        for (int i = 0; i < 3; i++) {
            for (int j = 0; j < 3-i; j++) {
                if(arr[j].getAge()<arr[j+1].getAge()){
                    tmp = arr[j];
                    arr[j] = arr[j+1];
                    arr[j+1] = tmp;
                }
            }
        }
    }

    public void say(Person p){
        if(p instanceof Teacher){
            ((Teacher) p).teach();
        }else if(p instanceof Student){
            ((Student) p).study();
        }
    }

    public void play(Person p){
        if(p instanceof Teacher){
            System.out.println(((Teacher) p).play());
        }else if(p instanceof Student){
            System.out.println(((Student) p).play());
        }
    }
}
